package free;

import sun.reflect.misc.ReflectUtil;

import java.awt.*;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

class Point{
    private int x;
    private int y;
    public Point(int x,int y){
        this.x=x;
        this.y=y;
    }

    public int getX() {
        return x;
    }

    public void setX(int x) {
        this.x = x;
    }

    public int getY() {
        return y;
    }

    public void setY(int y) {
        this.y = y;
    }

    @Override
    public String toString(){
        return "Point{"+"x="+x+",y="+y+"}";
    }
}

public class reflecttest {
  /*  public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException, NoSuchFieldException {
        //作业:
        Class<?> c1 = Class.forName("free.Point");
        Object o1 = ReflectUtil.newInstance("free.Point",new Object[]{10,20},int.class,int.class);
        Field f1 = c1.getDeclaredField("x");
        f1.setAccessible(true);
        f1.set(o1, 1000);
        System.out.println(o1);
        Method setMethod=c1.getDeclaredMethod("setX",int.class);
        setMethod.invoke(o1);
        Method getMethod = c1.getMethod("getX");
        Object getResult = getMethod.invoke(o1);
        System.out.println(getResult);

*/
}
